const Koa = require('koa');
const Router = require('koa-router');

const app = new Koa();
const router = new Router();

app.use(router.routes());
app.use(router.allowedMethods())

router.get('/product', async (ctx) => {
  ctx.body = [
    { id: 1, title: "iPad 4 Mini", price: 500.01, inventory: 2 },
    { id: 2, title: "H&M T-Shirt White", price: 10.99, inventory: 10 },
    { id: 3, title: "Charli XCX - Sucker CD", price: 19.99, inventory: 5 },
  ]
})

app.listen(4000, ()=> {
  console.log('服务已启动, 端口4000');
});